//
//  FMProgrameListenEngine.m
//  HuLaQuan
//
//  Created by liyan on 16/1/29.
//  Copyright © 2016年 yuwubao. All rights reserved.
//

#import "FMProgrameListenEngine.h"

@implementation FMProgrameListenEngine

-(void)getProgrammeList
{
    NSString *src = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"UTF-8\"?><msg service=\"GetProgrammeList\" User=\"%@\"></msg>",[CurrentUser sharedInstance].ID];
    //
    NSLog(@"%@ -- src --- ",src);
    
    //use Yu
    [YuHTTPClient XMLFMDataWithUrl:FM_SERVER_HOST parameters:src success:^(BOOL isSuccess, id item){
        
        NSDictionary *result;
        if (isSuccess) {
            result = @{@"isSuccess":@YES,@"result":item};
        }else{
            result = @{@"isSuccess":@NO,@"message":item};
        }
        //
        [[NSNotificationCenter defaultCenter] postNotificationName:@"GetProgrammeListFinish" object:result];
    }];
}

-(void)appointmentProgramme
{
    NSString *src = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"UTF-8\"?><msg service=\"Appointment\" User=\"%@\"><node><programmeID>1</programmeID><appointmentTime >2016-2-1 17:25:00</appointmentTime></node></msg>",[CurrentUser sharedInstance].ID];
    //
    NSLog(@"%@ -- src --- ",src);
    
    //use Yu
    [YuHTTPClient XMLFMDataWithUrl:FM_SERVER_HOST parameters:src success:^(BOOL isSuccess, id item){
        
        NSDictionary *result;
        if (isSuccess) {
            result = @{@"isSuccess":@YES,@"result":item};
        }else{
            result = @{@"isSuccess":@NO,@"message":item};
        }
        //
        [[NSNotificationCenter defaultCenter] postNotificationName:@"AppointmentFinish" object:result];
    }];
}

-(void)appointmentList
{
    NSString *src = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"UTF-8\"?><msg service=\"AppointmentList\" User=\"%@\"></msg>",[CurrentUser sharedInstance].ID];
    //
    NSLog(@"%@ -- src --- ",src);
    
    //use Yu
    [YuHTTPClient XMLFMDataWithUrl:FM_SERVER_HOST parameters:src success:^(BOOL isSuccess, id item){
        
        NSDictionary *result;
        if (isSuccess) {
            result = @{@"isSuccess":@YES,@"result":item};
        }else{
            result = @{@"isSuccess":@NO,@"message":item};
        }
        //
        [[NSNotificationCenter defaultCenter] postNotificationName:@"AppointmentListFinish" object:result];
    }];
}

-(void)programemListen:(NSString *)programeID andChannelName:(NSString *)channelName
{
    NSString *src = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><msg service=\"ProgrammeListen\" User=\"%@\"><node><programmeID>%@</programmeID><channelName>%@</channelName></node></msg>",[CurrentUser sharedInstance].ID,programeID,channelName];
    //
    NSLog(@"%@ -- src --- ",src);
    
    //use Yu
    [YuHTTPClient XMLFMDataWithUrl:FM_SERVER_HOST parameters:src success:^(BOOL isSuccess, id item){
        
        NSDictionary *result;
        if (isSuccess) {
            result = @{@"isSuccess":@YES,@"result":item};
        }else{
            result = @{@"isSuccess":@NO,@"message":item};
        }
        //
        [[NSNotificationCenter defaultCenter] postNotificationName:@"ProgrammeListenFinish" object:result];
    }];
}

@end
